using AnQinFrameWorkAPI.Entity.Finance.DTO.FinanceDetail;
using AnQinFrameWorkAPI.Entity.Finance.View.FinanceDetail;
using AnQinFrameWorkAPI.Service.Finance;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Finance;

/// <summary>
///     财务明细API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Finance")]
public class FinanceDetailController : ControllerBase
{
    //业务接口
    private readonly FinanceDetailService _financeDetailService;

    //构造注入
    public FinanceDetailController(FinanceDetailService financeDetailService)
    {
        _financeDetailService = financeDetailService;
    }

    /// <summary>
    ///     获取财务明细列表
    /// </summary>
    [ProducesResponseType(typeof(FinanceDetailView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetFinanceDetailList([FromQuery] FinanceDetailSearchDTO financeDetailSearchDTO)
    {
        var response = await _financeDetailService.GetFinanceDetailList(financeDetailSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增财务明细
    /// </summary>
    [HttpPost]
    public async Task<IActionResult> AddFinanceDetail([FromBody] FinanceDetailAddDTO financeDetailAddDTO)
    {
        var response = await _financeDetailService.AddFinanceDetail(financeDetailAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     编辑财务明细
    /// </summary>
    [HttpPut]
    public async Task<IActionResult> PutFinanceDetail([FromBody] FinanceDetailUpdateDTO financeDetailUpdateDTO)
    {
        var response = await _financeDetailService.PutFinanceDetail(financeDetailUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除财务明细
    /// </summary>
    [HttpDelete]
    public async Task<IActionResult> DeleteFinanceDetail([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _financeDetailService.DeleteFinanceDetail(deleteDTO);
        return StatusCode(response.Status, response);
    }
}